function fight() {
    // public
    this.title = "拼搏";
    this.divId = "openmodel";
    this.hide = function() {
        document.getElementById("fight").style.display="none";
    };
    this.unhide = function() {
        document.getElementById("fight").style.display="block";
    };

    // private
    var canvas_fight = document.getElementById("canvas_fight");
    var div = document.getElementById("fight");
    var ctx = canvas_fight.getContext("2d");
    var num = 100;
    var width = 100;
    var height = canvas_fight.height/num;
    var index_fight = 1;
    var time_fight;
    var time_show;
    var img_width = 0, img_height = 0;
    canvas_fight.width = screen.width;
    canvas_fight.height=screen.height;
    ctx.font="20px Georgia";
    ctx.strokeText("长按屏幕来观看动画",10,30);
    registeTouchEvent();
    var img_figth = new Image();
    img_figth.src="./images/4.png";
    img_figth.onload = function(){
        img_width = img_figth.width;
        img_height = img_figth.height;
    }

    function registeTouchEvent(){
        canvas_fight.addEventListener('touchstart',touchDown);
        canvas_fight.addEventListener('touchend',touchUp);
        canvas_fight.addEventListener('touchmove',touchMove);
    }

    function touchDown(){
        if(null == time_fight){
            time_fight = window.setTimeout(function(){
                ctx.clearRect(0,100, canvas_fight.width, canvas_fight.height);
                if(null == time_show){
                    //alert("timefilght go");
                    time_show = window.setInterval(function(){
                        if(index_fight > num){
                            index_fight = 0;
                            clearInterval(time_show);
                            time_show = null;
                        }else{
                            drawByIndex(index_fight);
                            index_fight++;
                        }
                    }, 20);
                }
            }, 800);
        }

    }
    function touchUp(){
        if(time_fight){
            clearTimeout(time_fight);
            time_fight = null;
        }
    }
    function touchMove(){

    }

    function drawByIndex(index){
        var heightTotal = (canvas_fight.height/4/num)*index_fight;
        var x = (canvas_fight.width - img_width)/2;
        var y  = (canvas_fight.height - img_height) -heightTotal;
        ctx.save();
        ctx.clearRect(0,150, canvas_fight.width, canvas_fight.height);
        ctx.drawImage(img_figth, x, y, img_width,img_height);
        //ctx.fillRect((canvas_fight.width - width)/2, (canvas_fight.height - heightTotal),width, heightTotal);
        ctx.restore();
    }

}